\documentclass[10pt, a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[cm, empty]{fullpage}
\usepackage{amsmath}
\usepackage{hyperref}
\setlength{\parindent}{1cm}
\usepackage{graphicx}
\usepackage{subfig}
%\usepackage{setspace}
%\onehalfspacing


\begin{document}
%\title{CS-440 ACG - Exercise 2}
%\author{Mihai Moraru, Kostiantyn Pupykin}
%\date{December 7, 2011}
%\maketitle
\begin{center} \huge CS-440 ACG -- Exercise 5\end{center}
\begin{center} Mihai Moraru, Kostiantyn Pupykin\end{center}

\section*{}
We dedicated to this project 40h. Out of this considerable amount of time, more than half was lost due to technical problems (without any exageration).
More specifically, the combination of integrated Intel graphics card with OpenGL on GNU/Linux gave us a lot of headaches.
Of course, we tried a Microsoft Windows platform too with Visual Studio 2010 installed.
The problem with this approach was a weird bug in some parallelization routine in CRT (Micosoft C++ library implementation): some threading routine (!)in "mlock.c" and another file.
The problem persisted even when starting with a clean solution.
We couldn't figure out this bug so in the end we were forced to develop on the workstations in the BC computer lab.

Even without taking into consideration the time spent on technical problems, we still dedicated quite a lot of time (20h) to the project itself.
We estimate this was mainly because we didn't participate in the Introduction to Computer Graphics class. GLSL was the main "enemy".
One also has to take into account the time consuming nature of generating procedural terrain.

\section*{5.1 Height field}
We followed closely the instructions given in the handout and we didn't have any big surprises. We chose to draw the terrain using GL\_TRIANGLE\_STRIP to avoid drawing a vertex multiple times.

We included the standard Perlin noise and the hybrid multifractal we developed for 5.3.
\begin{figure}[h]
        \caption{Height field}
        \centering
        \subfloat[Perlin noise] {
                \includegraphics[type=png,ext=.png,read=.png,width=.45\textwidth]{5.1.inoise}
        }
        \qquad
        \subfloat[Hybrid multifractal] {
                \includegraphics[type=png,ext=.png,read=.png,width=.45\textwidth]{5.1.hybridmultifractal}
        }
\end{figure}

\section*{5.2 Height field normals}
This was tricky. We lost a lot of time due to lighting errors in the given framework (\texttt{lightposition} not set).
We chose to compute all the normals in the first\_draw section and store them in the \texttt{terrain\_normal} matrix.

Although the formulas for computing the normals were correct, we forgot to take into account the actual position of the drawn vertices: in glVertex3f() we translated the x and z coordinates from [0, 512) to the interval [-1, 1). This lead to normals which were pointing almost straight up.

\begin{figure}[h]
        \caption{Height field normals}
        \centering
        \subfloat[Perlin noise] {
                \includegraphics[type=png,ext=.png,read=.png,width=.45\textwidth]{5.2.inoise}
        }
        \qquad
        \subfloat[Hybrid multifractal] {
                \includegraphics[type=png,ext=.png,read=.png,width=.45\textwidth]{5.2.hybridmultifractal}
        }
\end{figure}

\section*{5.3 Heterogeneous/hybrid terrain}
We had implemented only Perlin noise for Exercise 4.
For Exercise 5 we inspired heavily from \emph{Texturing and Modelling - A Procedural Approach}: we translated HybridMultifractal and RidgedMultifractalto GLSL.

\begin{figure}[h]
        \caption{Heterogeneous/hybrid terrain}
        \centering
        \subfloat[Ridged multi fractal] {
                \includegraphics[type=png,ext=.png,read=.png,width=.45\textwidth]{5.3.ridgedmultifractal}
        }
\end{figure}

\section*{5.4 Texturing}
For texturing, we defined 4 heights corresponding to the four textures. For each height we assign the color corresponding to each texture. In between, we blend the colors. Displacing the 2 thresholds corresponding to medium and high using a sinus with spatial frequency depending on x and z didn't bring any improvements.

For the ridged multifractal we obtained some erg-like terrain so we decided to apply a sand-like texture.

\begin{figure}[h]
        \caption{Texturing}
        \centering
        \subfloat[Moria (Hybrid multifractal)] {
                \includegraphics[type=png,ext=.png,read=.png,width=.45\textwidth]{5.4.hybridmultifractal}
        }
        \qquad
        \subfloat[Ergs (Ridged multifractal)] {
                \includegraphics[type=png,ext=.png,read=.png,width=.45\textwidth]{5.4.ridgedmultifractal}
        }
\end{figure}

\section*{Comments}
No time for comments. Except that finding good parameters for procedural terrain is hard.

\end{document}
